import { ApiProperty } from '@nestjs/swagger';
import { IsEmail, IsString, MinLength, Length, Matches, IsNotEmpty } from 'class-validator';

export class RegisterDto {
  @ApiProperty({ 
    description: '用户名', 
    example: 'johndoe',
    minLength: 3,
    maxLength: 16 
  })
  @IsString({ message: '用户名必须是字符串' })
  @IsNotEmpty({ message: '用户名不能为空' })
  @MinLength(3, { message: '用户名长度不能少于3个字符' })
  @Length(3, 16, { message: '用户名长度必须在3到16个字符之间' })
  @Matches(/^[a-zA-Z][a-zA-Z0-9_]*$/, {
    message: '用户名必须以字母开头，并且只能包含字母、数字或下划线',
  })
  username: string;

  @ApiProperty({ 
    description: '邮箱地址', 
    example: 'user@example.com' 
  })
  @IsEmail({}, { message: '请提供有效的邮箱地址' })
  @IsNotEmpty({ message: '邮箱不能为空' })
  email: string;

  @ApiProperty({ 
    description: '密码', 
    example: 'password123',
    minLength: 6 
  })
  @IsString({ message: '密码必须是字符串' })
  @IsNotEmpty({ message: '密码不能为空' })
  @MinLength(6, { message: '密码长度不能少于6个字符' })
  password: string;

  @ApiProperty({ 
    description: '确认密码', 
    example: 'password123',
    minLength: 6 
  })
  @IsString({ message: '确认密码必须是字符串' })
  @IsNotEmpty({ message: '确认密码不能为空' })
  @MinLength(6, { message: '确认密码长度不能少于6个字符' })
  confirmPassword: string;
} 